/**
 * 带头节点的链表a，是否对称
 */

class CircleLinkedList
{
public:
    int data;
    CircleLinkedList *next;
    CircleLinkedList *prior;

    CircleLinkedList();
    ~CircleLinkedList();
};

int solution(CircleLinkedList *l)
{
    CircleLinkedList *to_right = l->next;
    CircleLinkedList *to_left = l->prior;
    //第一个条件是用来判断奇数个元素的
    //第二个条件判断偶数个元素
    while (to_right != to_left && to_left->next != to_right)
    {
        if (to_right->data == to_left->data)//如果相等，就同时移动
        {
            to_right = to_right->next;
            to_left = to_left->next;
        }
        else//否则不满足条件直接返回
        {
            return 0;
        }
    }
    return 1;
}